package hu.u_szeged.inf.ovrt.filelister.ui;

import static hu.u_szeged.inf.ovrt.filelister.core.beans.Colors.PROMPT;

import java.awt.Color;

import enigma.console.Console;
import enigma.console.TextAttributes;
import enigma.core.Enigma;

/**
 * User interface implementation.
 */
public class SimpleUserInterface implements UserInterface {
    private static final Console CONSOLE;

    static
    {
        CONSOLE = Enigma.getConsole();
    }

    @Override
    public synchronized void print(String msg, Color color) {
        CONSOLE.setTextAttributes(new TextAttributes(color));
        System.out.print(msg);
        CONSOLE.setTextAttributes(new TextAttributes(PROMPT));
    }

    @Override
    public synchronized void printLn(String msg, Color color) {
        CONSOLE.setTextAttributes(new TextAttributes(color));
        System.out.println(msg);
        CONSOLE.setTextAttributes(new TextAttributes(PROMPT));
    }

    @Override
    public String readLn() {
        return CONSOLE.readLine();
    }
}
